import { AppContext } from "../app.context";

Component({
  data: {
    isHidden: false,
    active: 0,
    list: [
      {
        icon: 'icon-yinle',
        iconActivity: 'icon-yinle1',
        text: '首页',
        url: '../index/index'
      },
      {
        icon: 'icon-xiangce1',
        iconActivity: 'icon-xiangce',
        text: '相册',
        url: '../photo/photo'
      },
      {
        icon: 'icon-wodewo',
        iconActivity: 'icon-wode-mianxing',
        text: '我的',
        url: '../mine/mine'
      }
    ]
  },
  attached() {

  },
  methods: {
    onChange(e: any) {
      console.log(e);
      const active = e.currentTarget.dataset.active
      this.setData({ active: active });
      const url = this.data.list[active].url;
      AppContext.instance.setTabbarActive(active)
      wx.switchTab({ url });
    },

    init() {
      this.setData({ active: AppContext.instance.tabbarActive });
    },

    /** 是否隐藏 Tabbar */
    hidden() {
      this.setData({ isHidden: !this.data.isHidden });
    }
  }

})